package hanjia;

import java.util.ArrayList;
import java.util.List;

/**
 * Description:
 * Author:    Dane
 * CreateTime:2025/2/11-下午10:02
 * Since  :   1.0
 * Version:   1.0
 */
public class LeetCode98 {

    public boolean isValidBST(TreeNode root) {

        ArrayList<Integer> result = new ArrayList<>();
         inOrder(root,result);
        for (int i = 1; i < result.size(); i++) {
            if (result.get(i)<= result.get(i-1)){
                return false;
            }

        }
        return true;

    }

    private void inOrder(TreeNode root, ArrayList<Integer> result) {
        if (root==null){
            return;
        }

        inOrder(root.left,result);
        result.add(root.val);
        inOrder(root.right,result);

    }


}
